#include "jDataLogging.h"


jDataLogging::jDataLogging()
{

	m_Collisions = 0;
	m_ReCalculations = 0;
	m_FileName = "NONE";
	m_AlgorithmType = "NONE";
	
	m_LevelName = "NONE";
	m_BotNumber = 0;
	m_Collisions = 0 ;
	m_CollisionsString = "0";
	m_BotNumberString = "0";
	m_ReCalculationsString = "0";
	m_FramesPerSecoundString = "0";
}

bool jDataLogging::clearData()
{

	m_Collisions = 0;
	m_ReCalculations = 0;
	m_FileName = "NONE";
	m_AlgorithmType = "NONE";
	
	m_LevelName = "NONE";
	m_BotNumber = 0;
	m_Collisions = 0 ;
	m_CollisionsString = "0";
	m_BotNumberString = "0";
	m_ReCalculationsString = "0";
	m_FramesPerSecoundString = "0";
	
	return true;

}

jDataLogging::~jDataLogging()
{
	fileIO.recieveData("00/00/00",m_LevelName,m_AlgorithmType,"TICKSXX",m_BotNumberString,m_ReCalculationsString,m_CollisionsString);
	fileIO.writeToFile(m_FileName);
}

void jDataLogging::setInfo(string fileName, string algType)
{
m_FileName = fileName;
m_AlgorithmType = algType;
}

void jDataLogging::setMapName(string mapName)
{
m_LevelName = mapName;
}

void jDataLogging::addAgentAmount()
{
	 m_BotNumber++;

 	std::stringstream out;
	out << m_BotNumber;
	m_BotNumberString = out.str();
}

void jDataLogging::setAgentAmount(int amount)
{
	m_BotNumber = amount;

	std::stringstream out;
	out << m_BotNumber;
	m_BotNumberString = out.str();
}

void jDataLogging::addCollision()
{
	m_Collisions++;

	std::stringstream out;
	out << m_Collisions;
	m_CollisionsString = out.str();
}

void jDataLogging::addRecalculation()
{
	m_ReCalculations++;

	std::stringstream out;
	out << m_ReCalculations;
	m_ReCalculationsString = out.str();

}

void jDataLogging::setFPS(float fps)
{

	m_FramesPerSecound = fps;

	std::stringstream out;
	out << m_FramesPerSecound;
	m_FramesPerSecoundString = out.str();

}

void jDataLogging::addPathSearchTime(int ticks)
{
	m_ReCalculationsTimeCont.push_back(ticks);
}

void jDataLogging::setElapsedTime(float time)
{
	m_ElapsedTime = time;

	std::stringstream out;
	out << m_ElapsedTime;
	m_ElapsedTimeString = out.str();
}
void jDataLogging::RenderGui()
{

	gdi->TextColor(255,0,0);
	gdi->TextAtPos(10,400, "Algorithm:");
	gdi->TextAtPos(80,400, m_AlgorithmType);
	gdi->TextAtPos(200,400, m_FileName);

	gdi->TextAtPos(10,500, "Time since Start");
	gdi->TextAtPos(10,520, m_ElapsedTimeString);

	gdi->TextAtPos(200,500, "Num of Agents");
	gdi->TextAtPos(200,520, m_BotNumberString);

	gdi->TextAtPos(370,500, "Pathfinding Calculations");
	gdi->TextAtPos(370,520, m_ReCalculationsString);

	gdi->TextAtPos(600,500, "Collisions");
	gdi->TextAtPos(600,520, m_CollisionsString);

	gdi->TextAtPos(600,400, "FPS");
	gdi->TextAtPos(600,420, m_FramesPerSecoundString);

}
